package com.example.treehole.utils;

import android.content.Context;

import com.example.treehole.R;

import java.util.HashMap;
import java.util.Map;

public class DynamicColorUtils {

    public static Context mContext;

    public static Map<String,Integer> getItemColorsByScore(Context context, double score){
        mContext=context;
        Map<String,Integer> colors=new HashMap<>();
        if (score >=0 && score < 0.3){
            colors.put("bgColor", getColorId(R.color.scoreOneBg));
            colors.put("timeColor",getColorId(R.color.scoreOneTime));
            colors.put("titleColor",getColorId(R.color.scoreOneTitle));
            colors.put("contentColor",getColorId(R.color.scoreOneContent));
        }else if (score < 0.5){
            colors.put("bgColor", getColorId(R.color.scoreTwoBg));
            colors.put("timeColor",getColorId(R.color.scoreTwoTime));
            colors.put("titleColor",getColorId(R.color.scoreTwoTitle));
            colors.put("contentColor",getColorId(R.color.scoreTwoContent));
        }else if (score < 0.7){
            colors.put("bgColor",getColorId(R.color.scoreThreeBg));
            colors.put("timeColor",getColorId(R.color.scoreThreeTime));
            colors.put("titleColor",getColorId(R.color.scoreThreeTitle));
            colors.put("contentColor",getColorId(R.color.scoreThreeContent));
        }else{
            colors.put("bgColor",getColorId(R.color.scoreFourBg));
            colors.put("timeColor",getColorId(R.color.scoreFourTime));
            colors.put("titleColor",getColorId(R.color.scoreFourTitle));
            colors.put("contentColor",getColorId(R.color.scoreFourContent));
        }
        return colors;
    }

    public static int getColorId(int id){
        return mContext.getResources().getColor(id);
    }
}
